import { ref} from 'vue';
import { handleChartResize } from '@/utils/base';
import echarts from '@/echarts';
export default function () {
  const container = ref(null)
  const chartRef = ref(null)
  chartRef.value = echarts.init(container.value);
  function getOption () {
    
  }
  function initChart () { }
  function resetFontSize () {
    const option = getOption();
    delete option.series;
    // 需要重新计算字体不然依旧会有点偏差
    chartRef.value && chartRef.value.setOption(option);
  }
  function resizeChart () {
    if (chartRef.value) {
      handleChartResize(chartRef.value);
      resetFontSize();
    }
  }
  return {
    container,
    getOption,
    initChart
  }
}